<template>
  <div>
    <TaBle
      :list.sync="data"
      :show="bul"
      :page.sync="page"
      :but="true"
      :total.sync="total"
      :pageIndex.sync="page.pageIndex"
      :pageSize.sync="page.pageSize"
      :totalPage.sync="page.totalPage"
      :isRepair="page.isRepair"
      v-loading="loading"
    />
  </div>
</template>
<script>
import { search } from '@/api/business'
import TaBle from './components/table.vue'
export default {
  name: 'DekedeIndex',
  components: {
    TaBle
  },
  data () {
    return {
      searchList: [],
      data: [],
      page: {
        pageIndex: 1,
        pageSize: 10,
        isRepair: false
      },
      total: 0,
      bul: true,
      loading: false
    }
  },
  created () {
    this.search()
  },
  methods: {
    // 工单搜索
    async search () {
      try {
        this.loading = true
        const res = await search(this.page)
        console.log(res)
        this.searchList = res.currentPageRecords
        this.page.pageIndex = res.pageIndex
        this.page.pageSize = res.pageSize
        this.page.totalPage = res.totalPage
        this.total = res.totalCount
        const b = []
        const a = this.searchList.map((item) => {
        // console.log(JSON.stringify(item.createTime).replace('T', ' '))
          if (item.taskType.typeName !== null) {
            b.push({
              taskCode: item.taskCode,
              userName: item.userName,
              createTime: JSON.parse(
                JSON.stringify(item.createTime).replace('T', ' ')
              ),
              statusName: item.taskStatusTypeEntity.statusName,
              typeName: item.taskType?.typeName,
              innerCode: item.innerCode,
              taskId: item.taskId,
              productTypeId: item.productTypeId,
              createType: item.createType === 1 ? '手动' : '自动'
            })
          }
          return b[0]
        })
        this.data = a
      } catch (error) {
        console.log(error)
      } finally {
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
